package com.mp.approvalreq.dao;

import com.mp.approvalreq.entity.Request;

import java.sql.SQLException;
import java.util.List;

public interface RequestDao {
    /**
     * 根据id批量查审批
     *
     * @param requestIds
     * @return
     * @throws SQLException
     */
    List<Request> selectRequestByIds(String requestIds) throws SQLException;

    /**
     * 查询用户申请的审批id集合
     *
     * @param query
     * @return
     * @throws SQLException
     */
    @Deprecated
    List<Integer> selectRequestIdsByCompanyInfoId(Request query) throws SQLException;

    /**
     * 查询用户申请的审批id集合
     *
     * @param proxyContactId
     * @param companyInfoId
     * @param finishedSequence
     * @param orderBy
     * @return
     * @throws SQLException
     */
    List<Integer> selectRequestIdsByCompanyInfoId(Integer proxyContactId, Integer companyInfoId, String finishedSequence, String orderBy) throws SQLException;

    /**
     * 查询用户指定身份申请的审批id集合
     *
     * @param contactId
     * @param orderBy
     * @return
     * @throws SQLException
     */
    List<Integer> selectRequestIdsByContactId(Integer contactId, String orderBy) throws SQLException;

    /**
     * 获取用户尚未处理的审批id
     *
     * @param companyId
     * @param companyInfoId
     * @return
     * @throws SQLException
     */
    List<Integer> selectUserNotApprovedRequestIds(Integer companyId, Integer companyInfoId) throws SQLException;

    /**
     * 批量修改审批人信息
     *
     * @param requests
     * @param companyId
     * @throws SQLException
     */
    void updateRequestUsersBatch(List<Request> requests, Integer companyId) throws SQLException;

    /**
     * 批量修改审批抄送信息
     *
     * @param requests
     * @throws SQLException
     */
    void updateRequestCcBatch(List<Request> requests) throws SQLException;

    /**
     * 更新审批流信息
     *
     * @param request
     * @throws SQLException
     */
    void updateRequestInfo(Request request) throws SQLException;

    /**
     * 根据id查询审批详情
     *
     * @param requestId
     * @return
     * @throws SQLException
     */
    Request selectRequestDetailById(Integer requestId) throws SQLException;

    /**
     * 保存审批流信息
     *
     * @param request
     * @throws SQLException
     */
    void insertRequestInfo(Request request) throws SQLException;

    /**
     * 更新审批抄送信息（抄送人和抄送状态）
     *
     * @param request
     * @throws SQLException
     */
    void updateRequestCcInfo(Request request) throws SQLException;

    /**
     * 更新销假信息（兼容逻辑,后期作废）
     *
     * @param request
     * @throws SQLException
     */
    void updateRequestPauseLeaveInfo(Request request) throws SQLException;

    /**
     * 批量修改
     *
     * @param requestToUpdate
     * @throws SQLException
     */
    void updateBatchRequestLeaveInfo(List<Request> requestToUpdate) throws SQLException;

    /**
     * 查看指定时间范围内模板下的审批列表
     *
     * @param templateId
     * @param startDate
     * @param endDate
     * @return
     * @throws SQLException
     */
    List<Request> selectTemplateRequestDetailByDateScope(Integer templateId, String startDate, String endDate) throws SQLException;

    /**
     * 查看指定时间范围内模板下用户申请的审批列表
     *
     * @param companyInfoId
     * @param templateId
     * @param startDate
     * @param endDate
     * @return
     * @throws SQLException
     */
    List<Request> selectUserTemplateRequestDetailByDateScope(Integer companyInfoId, Integer templateId, String startDate, String endDate) throws SQLException;

    /**
     * 根据审批id获取最新的审批
     *
     * @param companyId
     * @param requestIds
     * @return
     * @throws SQLException
     */
    List<Request> selectNewestRequestByIds(Integer companyId, String requestIds) throws SQLException;

    /**
     * 修改审批操作信息
     *
     * @param request
     * @throws SQLException
     */
    void updateRequestOperation(Request request) throws SQLException;

    List<Integer> selectRequestIdsByAncestorId(Integer id) throws SQLException;

    List<Request> selectUserRequestByTemplateIds(Integer companyId, Integer contactId, String month, String templateIds) throws SQLException;

    List<Integer> selectUsualTemplateAncestorIds(Integer companyId, Integer companyInfoId) throws SQLException;
}
